import MyTable from '@/components/MyTable';
import { getByMiniSerachList } from '@/services/agent';
import { findByPageBackAgentList } from '@/services/users';
import { Link } from '@umijs/max';
import React from 'react';
const columns = [
  {
    title: '编号',
    dataIndex: 'id',
    search: false,
    key: 'id',
  },
  {
    title: '授权编号',
    dataIndex: 'invite',
    key: 'invite',
  },
  {
    title: '头像',
    dataIndex: 'avatar',
    valueType: 'avatar',
    key: 'avatar',
    search: false,
  },
  {
    title: '姓名',
    dataIndex: 'name',
    key: 'name',
    render: (
      _: any,
      row: API.AgentInvitationRelationship,
      index: number,
      action: any,
    ) => {
      return (
        <Link target="_blank" to={'/users/tree?userId=' + row?.id}>
          {_}
        </Link>
      );
    },
  },

  /*  {
    title: '下级',
    dataIndex: 'agentCount',
    search: false,
    key: 'agentCount',
  },*/
  {
    title: '手机号',
    dataIndex: 'phone',
    key: 'phone',
  },
  {
    title: '邀请人',
    dataIndex: 'parentName',
    key: 'parentName',
  },
  {
    title: '代理等级',
    dataIndex: 'agentName',
    search: false,
    key: 'agentName',
  },
  {
    title: '代理等级',
    dataIndex: 'agentId',
    key: 'agentId',
    valueEnum: await getByMiniSerachList(0),
    valueType: 'select',
    hideInTable: true,
  },
  {
    title: '时间',
    dataIndex: 'createDate',
    valueType: 'dateTime',
    hideInSearch: true,
    key: 'createDate',
  },

  {
    title: '操作',
    width: '164px',
    key: 'option',
    valueType: 'option',
    render: (
      _: any,
      row: API.AgentInvitationRelationship,
      index: number,
      action: any,
    ) => [
      <Link key="link" to={'/users/show/' + row.id}>
        详细
      </Link>,
    ],
  },
];
export const Index: React.FC = () => {
  //userstatus
  return (
    <MyTable
      search={true}
      request={findByPageBackAgentList}
      columns={columns}
    />
  );
};
export default Index;
